package com.itheima.web.controller.oms;


import com.itheima.service.oms.IOmsOrderSettingService;
import com.itheima.utils.ResultData;
import com.itheima.vo.oms.OmsOrderSetting;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 订单设置表 前端控制器
 * </p>
 *
 * @author 王志斌
 * @since 2022-07-06
 */
@RestController
@RequestMapping("/orderSetting")
public class OmsOrderSettingController {
    @DubboReference
    private IOmsOrderSettingService orderSettingService;

    /**
     * 修改指定订单设置
     *
     * @param id:订单设置表中的主键id(按理说是订单id)
     * @param orderSetting:订单设置数据
     * @return
     */
    @PostMapping("/update/{id}")
    public ResultData update(@PathVariable Integer id, @RequestBody OmsOrderSetting orderSetting) {
        Integer count = orderSettingService.update(id, orderSetting);
        if (count == 0) {
            return ResultData.error("修改失败");
        }
        return ResultData.ok("修改成功!","");
    }

    /**
     * 获取指定订单设置
     *
     * @param id：订单设置表中的主键id(按理说是订单id)
     * @return
     */
    @GetMapping("/{id}")
    public ResultData findById(@PathVariable Integer id) {
        OmsOrderSetting orderSetting = orderSettingService.findById(id);
        if (orderSetting == null) {
            return ResultData.error("查询有误");
        }
        return ResultData.ok("",orderSetting);
    }

}
